package com.sbio.udiapp.net.exception;

import com.sbio.udiapp.util.DialogUtil;

import java.util.function.Consumer;

public class ErrorConsumerAdapter extends ErrorConsumer<Throwable> {

    public Consumer<Throwable> before;

    public Consumer<Throwable> after;

    @Override
    public void error(ApiException ex) {
        //todo 打个日志记录一下错误
        if (before != null) {
            before.accept(ex);
        }
        //添加提示框
        DialogUtil.showCommonAlertDialog(ex.getErrMsg(),()->{
            if (after != null) {
                after.accept(ex);
            }
        });
    }

}
